using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Decav.Gatsb.Application;
using Decav.Gatsb.Data;
using Decav.Gatsb.Messaging;
using System.Web.UI.MobileControls;
using System.Collections.Generic;

public partial class Inbox : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InboxMessage[] messages = null;
            using (IGatsbDataAdapter adapt = GatsbApplication.Current.GetDataAdapter())
                messages = adapt.GetMessages(MessageStatus.Unspecified);

            if (messages.Length == 0)
            {
                friendRequestRepeater.Visible = false;
                noRequestsDiv.Visible = true;
            }
            else
            {
                // Nice hack to let our add friends work.
                List<Decav.Gatsb.User> users = new List<Decav.Gatsb.User>();
                using (IGatsbDataAdapter adapt = GatsbApplication.Current.GetDataAdapter())
                {
                    foreach (InboxMessage msg in messages)
                        users.Add(adapt.GetUser(msg.SenderId));
                }

                friendRequestRepeater.Visible = true;
                noRequestsDiv.Visible = false;

                friendRequestRepeater.DataSource = users;
                friendRequestRepeater.DataBind();
            }
        }
    }
}
